#ifndef MATLABC_H
#define MATLABC_H
#include <tbb/parallel_for.h>
#include <tbb/tbb.h>
#include <tbb/mutex.h>
#include <opencv2/core.hpp>
#include <opencv2/opencv.hpp>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <chrono>
#include <cmath>
#include <numeric>
#include <tbb/parallel_invoke.h>

using namespace cv;
using namespace std;

struct FitCircle
{
    double x;
    double y;
    double r;
    double rd0;
};

struct ImageMean {
    std::string name;
    double mean_x;
    double mean_y;
    double mean_r;
};

struct LocCircleResult
{
    int center_x;
    int center_y;
    int circle_rad;
    int ring_ex_rad;
    int ring_in_rad;
};

struct Coeff
{
    double a0;
    double a1;
    double a2;
};

//粗定位
LocCircleResult CoarseLocation(const cv::Mat& im);

LocCircleResult CoarseLocation1(const cv::Mat& im);

//圆拟合
FitCircle CircleFit1(const std::vector<cv::Point>& points);

FitCircle CircleFit1(const std::vector<float>& x_pos,const std::vector<float>& y_pos);

//设置圆模板
cv::Mat CreateCircleTemplate(int radius,int wid);

//设置圆环模板
cv::Mat CreateRingTemplate(int ring_ex_rad,int ring_in_rad,int wid);

//裁剪圆
cv::Mat CropCircleImage(const cv::Mat& image,const struct LocCircleResult& L,int cut_wid);

//裁剪圆环
cv::Mat CropRingImage(const cv::Mat& image,const struct LocCircleResult& L,int cut_wid);

//平面方程
Coeff PlaneSolu(const std::vector<cv::Point3f>& points_in);

//提取有效数据点
void ExtractNZero(const cv::Mat& image,int center_x,int center_y,int radius,int cut_wid,std::vector<cv::Point3f>& points3f);

//校正图像灰度
cv::Mat CorrectGray(const cv::Mat& image,const struct Coeff& coeff,cv::Mat& im_lo,int center_x,int center_y,int radius,int cut_wid);

//特定插值
void ProcessInterp(const cv::Mat& temp,std::vector<float>& fitx_pos,std::vector<float>& fity_pos,int center_x,int center_y,int radius,int cut_wid);

//均值
double Mean(std::vector<float>& vec);
//
//class matlabc
//{
//public:
//    matlabc();
//};

#endif // MATLABC_H
